#include <bits/stdc++.h>
using namespace std;

struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};

class Solution {
public:
    ListNode* swapPairs(ListNode* head) {
        if(head == NULL) return NULL;
        ListNode *fp = NULL, *p = head, *ap;
        if(p != NULL){
            ap = p->next;
        }
        if(ap != NULL) head = ap;

        while(ap != NULL){
            if(fp != NULL){
                fp->next = ap;
            }
            p->next = ap->next;
            ap->next = p;

            fp = p;
            p = p->next;
            if(p == NULL) break;
            ap = p->next;
        }

        return head;
    }
};

int main(){

}